package business;

import repository.VisitantRepository;
import classes.Iterator;
import classes.Visitant;
import exceptions.RepositoryException;

public class VisitantBusiness
{
	private VisitantRepository repository;
	
	public VisitantBusiness() throws RepositoryException
	{
		this.repository = VisitantRepository.getInstance();
	}
	
	public void add( Visitant visitant ) throws RepositoryException
	{
		if( visitant != null )
		{
			repository.add( visitant );
		}
		else
		{
			throw new NullPointerException();
		}
	}
	
	public void edit( Visitant visitant ) throws RepositoryException
	{
		if( visitant != null )
		{
			repository.edit( visitant );
		}
		else
		{
			throw new NullPointerException();
		}
	}
	
	public Iterator< Visitant > find( Visitant visitant ) throws RepositoryException
	{
		Iterator< Visitant > ret;
		
		if( visitant != null )
		{
			ret = repository.find( visitant );
		}
		else
		{
			throw new NullPointerException();
		}
		
		return ret;
	}
	
	public Visitant get( int id ) throws RepositoryException
	{
		return repository.get( id );
	}
	
	public Iterator< Visitant > getIterator() throws RepositoryException
	{
		return repository.getIterator();
	}
	
	public void remove( int id ) throws RepositoryException
	{
		repository.remove( id );
	}
	
	public int size() throws RepositoryException
	{
		return repository.size();
	}
}
